﻿using System.Xml.Serialization;
using PrearrangedChaos.AgileZen.Service.Rest;

namespace PrearrangedChaos.AgileZen.Service.Model
{
    [XmlType(AnonymousType = true)]
    [XmlRootAttribute(ElementName = "attachment", Namespace = "", IsNullable = false)]
    [ZenRestRequest("projects/{0}/stories/{1}/attachments/{2}")]
    public class AttachmentUpdater : ModelBase, IAttachmentUpdater
    {
        private string _fileName;

        /// <remarks/>
        [XmlElement(ElementName = "fileName")]
        public string FileNameXmlElement
        {
            get { return _fileName; }
            set
            {
                if (!string.IsNullOrEmpty(value))
                    _fileName = value;
                else
                    _fileName = null;

                this.Unmodified("filename");
            }
        }

        [XmlIgnore]
        public string FileName
        {
            get { return _fileName; }
            set
            {
                if (_fileName == value)
                    return;

                _fileName = value;
                this.Modified("filename");
            }
        }

        public bool FileNameXmlElementSpecified { get { return this.IsModified("filename"); } }
    }
}